#define _CRT_SECURE_NO_WARNINGS 
//#include<stdio.h>
//void is_narcissus(int n)
//{
//	int i = 0;
//	int j = 0;
//	int k = 0;
//	i = pow(10, n - 1);
//	j = pow(10, n);
//	int sum = 0;
//	for (k = i; k <= j; k++)
//	{
//		int temp = k;
//		sum = 0;
//		while (temp)
//		{
//			sum += pow(temp % 10, n);
//			temp /= 10;
//		}
//		if (sum == k)
//		{
//			printf("%d\n", k);
//		}
//	}
//}
//
//int main()
//{
//	int n = 0;
//	scanf("%d", &n);
//	is_narcissus(n);
//	return 0;
//}
#include<stdio.h>
int main()
{
	int n = 0;
	scanf("%d", &n);
	int arr[3][2];
	int i = 0;
	int j = 0;
	for (i = 0; i < 3; i++)
	{
		for (j = 0; j < 2; j++)
		{
			scanf("%d", &arr[i][j]);
		}
	}
	int a = 0;
	int a_remained = 0;
	int b = 0;
	int b_remained = 0;
	int c = 0;
	int c_remained = 0;
	int spend_1 = 0;
	int spend_2 = 0;
	int spend_3 = 0;
	a = n / arr[0][0];
	a_remained = n % arr[0][0];
	if (a_remained == 0)
	{
		spend_1 = arr[0][1] * a;
	}
	else if (a_remained != 0)
	{
		spend_1 = arr[0][1] * (a + 1);
	}
	b = n / arr[1][0];
	b_remained = n % arr[1][0];
	if (b_remained == 0)
	{
		spend_2 = arr[1][1] * b;
	}
	else if (b_remained != 0)
	{
		spend_2 = arr[1][1] * (b + 1);
	}
	c = n / arr[2][0];
	c_remained = n % arr[2][0];
	if (c_remained == 0)
	{
		spend_3 = arr[2][1] * c;
	}
	else if (c_remained != 0)
	{
		spend_3 = arr[2][1] * (c + 1);
	}
	int k[3];
	k[0] = spend_1;
	k[1] = spend_2;
	k[2] = spend_3;
	for (i = 0; i < 2; i++)
	{
		for (int j = 0; j < 2 - i; j++)
		{
			if (k[j] > k[j + 1])
			{
				int temp = 0;
				temp = k[j];
				k[j] = k[j + 1];
				k[j + 1] = temp;
			}
		}
	}
	printf("%d", k[0]);
	return 0;
}